﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Departamentos.aspx.cs" Inherits="SistemaFacturacionWeb.Formulario_web1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    
    <table class="auto-style1">
        <tr>
            <td style="text-align: right">Departamento:</td>
            <td>
                <asp:TextBox ID="TxtnuevoDepartamento" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidatorTxtnuevoDepartamento" runat="server" ControlToValidate="TxtnuevoDepartamento" ErrorMessage="Debe ingresar un departamento" ForeColor="#FF3300"></asp:RequiredFieldValidator>
            </td>
        </tr>
    </table>
    <asp:Button ID="BtnNuevoDepartamento" runat="server" Text="Guardar" OnClick="BtnNuevoDepartamento_Click"  />

    <p>
        <asp:GridView ID="GridViewDepartamentos" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="IDDepartamento" DataSourceID="SqlDataSource1" EmptyDataText="No hay registros de datos para mostrar." ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField HeaderText="Operaciones" ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="IDDepartamento" HeaderText="ID Departamento" ReadOnly="True" SortExpression="IDDepartamento" />
                <asp:BoundField DataField="Descripcion" HeaderText="Descripción" SortExpression="Descripcion" />
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" DeleteCommand="DELETE FROM [Departamento] WHERE [IDDepartamento] = @IDDepartamento" InsertCommand="INSERT INTO [Departamento] ([Descripcion]) VALUES (@Descripcion)" ProviderName="<%$ ConnectionStrings:FacturacionConnectionString1.ProviderName %>" SelectCommand="SELECT [IDDepartamento], [Descripcion] FROM [Departamento]" UpdateCommand="UPDATE [Departamento] SET [Descripcion] = @Descripcion WHERE [IDDepartamento] = @IDDepartamento">
            <DeleteParameters>
                <asp:Parameter Name="IDDepartamento" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Descripcion" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Descripcion" Type="String" />
                <asp:Parameter Name="IDDepartamento" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </p>
</asp:Content>
